import Vue from 'vue'
export default {
  state: {
    id: '',
    type: '',
    name: '',
    filterSql: '',
    routeMeta: [],
    botId: '',
    botDetail: '',
    botTemplateType: '',
    dataFromEidt: false,
    refreshBotList: 0,
    botInfoChangeStatus: false,
    botfromFlag: false,
    botdesignArcPidFlag: 100,
    Autotasklink: '',
    // syncroUserId: '',
    // kaseyabmsUserId: '',
    // autoTaskUserId: '',
    // nextTicketUserId: '',
    // syncroFilterId: '',
    // kaseyabmsFilterId: '',
    // autoTaskFilterId: '',
    // nextTicketFilterId: '',
    defaultWidget: '',
    dataFromWidget: false,
    defaultTab: false,
    botTabsIndex: '0',
    listFieldsRes:undefined,
    assignLicense: false,
    RealtimeBotsMessageReportforTeamsMessageFotterBotId:null
  },
  mutations: {
    SET_ASSIGN_LICENSE: (state, assignLicense) => {
      state.assignLicense = assignLicense
    },
    TRIGGER_SELECT_DATAID: (state, id) => {
      state.id = id
    },
    TRIGGER_SELECT_DATA_TYPE: (state, type) => {
      state.type = type
    },
    FILTERSQL: (state, data) => {
      state.filterSql = data
    },
    TRIGGER_SELECT_DATA_NAME: (state, name) => {
      state.name = name
    },
    ROUTEMETASTARAGE: (state, data) => {
      state.routeMeta = data
    },
    RECORDBOTID: (state, data) => {
      state.botId = data
    },
    BOTTEMPLATETYPE: (state, data) => {
      state.botTemplateType = data
    },
    BOTFORMEDIT: (state, data) => {
      state.dataFromEidt = data
    },
    REFRESHBOTLIST: (state, data) => {
      state.refreshBotList = data
    },
    BOTCONTENTCHANGE (state, data) {
      state.botInfoChangeStatus = data
    },
    BOTFORMFLAG (state, data) {
      state.botfromFlag = data
    },
    BOTDESIGNARCSTATUS (state, data) {
      state.botdesignArcPidFlag = data
    },
    STOREAUTOLINK: (state, id) => {
      state.Autotasklink = id
    },
    // SYNCRONEXTTICKETUSER: (state, id) => {
    //   state.syncroUserId = id
    // },
    // KASEYABMSNEXTTICKETUSER: (state, id) => {
    //   state.kaseyabmsUserId = id
    // },
    // AUTONEXTTICKETUSER: (state, id) => {
    //   state.autoTaskUserId = id
    // },
    // NEXTTICKETUSER: (state, id) => {
    //   state.nextTicketUserId = id
    // },
    // SYNCRONEXTTICKETFILTERID: (state, id) => {
    //   state.syncroFilterId = id
    // },
    // KASEYABMSNEXTTICKETFILTERID: (state, id) => {
    //   state.kaseyabmsFilterId = id
    // },
    // AUTONEXTTICKETFILTERID: (state, id) => {
    //   state.autoTaskFilterId = id
    // },
    // NEXTTICKETFILTERID: (state, id) => {
    //   state.nextTicketFilterId = id
    // },
    DEFAULTWIDGET: (state, gadgetId) => {
      state.defaultWidget = gadgetId
    },
    BOTFORMWIDGET: (state, data) => {
      state.dataFromWidget = data
    },
    DEFAULTTAB: (state, defaultTab) => {
      state.defaultTab = defaultTab
    },
    SETBOTDETAIL: (state, data) => {
      state.botDetail = data
    },
    BOTTABSINDEX: (state, data) => {
      state.botTabsIndex = data
    },
    LISTFIEDSRES:(state, data)=>{
      state.listFieldsRes = data
    }
  },
  actions: {
    setBotDetail ({ commit }, data) {
      commit('SETBOTDETAIL', data)
    },
    setAssignLicense ({ commit }, data) {
      commit('SET_ASSIGN_LICENSE', data)
    },
    triggerSelectDataId ({ commit }, id) {
      commit('TRIGGER_SELECT_DATAID', id)
    },
    triggerSelectDataIType ({ commit }, type) {
      commit('TRIGGER_SELECT_DATA_TYPE', type)
    },
    triggerSelectDataName ({ commit }, name) {
      commit('TRIGGER_SELECT_DATA_NAME', name)
    },
    routeMetaStor ({ commit, state }, data) {
      let tabList = JSON.parse(JSON.stringify(state.routeMeta))
      let falg = false
      tabList.forEach(element => {
        if (element.menuId === data.menuId) {
          element.title = data.title
          falg = true
        }
      })
      if (!falg) tabList.push(data)
      commit('ROUTEMETASTARAGE', tabList)
    },
    getListFieldsRes ({ commit }, res) {
      commit('LISTFIEDSRES', res)
    }
  }
}